/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean.session;

import entity.BillingRequestEntity;
import entity.DataObjectEntity;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Root;

/**
 *
 * @author wei
 */
@Stateless
public class BillingRequestEntityFacade extends AbstractFacade<BillingRequestEntity> {
    @PersistenceContext(unitName = "MacTeam-warPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public BillingRequestEntityFacade() {
        super(BillingRequestEntity.class);
    }
    
    public List<BillingRequestEntity> findAllCIARequests(){
        List<BillingRequestEntity> allCIARequests = new ArrayList<BillingRequestEntity>();
        for(BillingRequestEntity request : findAll()){
            if(request.getShippingOrders().isEmpty())
                allCIARequests.add(request);
        }
        return allCIARequests;
    }
    
    public List<BillingRequestEntity> findAllNormalRequests(){
        List<BillingRequestEntity> allNormalRequests = new ArrayList<BillingRequestEntity>();
        for(BillingRequestEntity request : findAll()){
            if(!request.getShippingOrders().isEmpty())
                allNormalRequests.add(request);
        }
        return allNormalRequests;
    }
    
}
